import os

from facade.sqlite3facade import Sqlite3Utiles
from logicaltool.sqltools.two_table_contrast import TableContrast
from xjlibrary.our_file_dir import BaseDir


class TableContrast2(TableContrast):
    def get_one_table_data(self):
        filePath="F:\\test\\sipopatent.db3"

        sqliteutiles = Sqlite3Utiles().Sqlite3DBConnectFromFilePath(filePath)
        sql = self.one_table_data_hook()
        rows = sqliteutiles.SelectFromSqlliteFetchall(sql)
        return rows

    def one_table_data_hook(self):
        sql = "select rawid,identifier_standard from modify_title_info_zt"
        return sql

    def get_other_table_data(self):
        pass

    def other_table_data_hook(self):
        pass

    def deal_data(self, rows):
        dicts = {}
        for rawid, identifier_standard in rows:
            dicts[rawid] = identifier_standard
        return dicts




tables2 = TableContrast2()
rows = tables2.get_one_table_data()
dicts2 = tables2.deal_data(rows)

# 需要处理目录的绝对路径
FileRoots = [r'\\192.168.30.177\样例数据\sipopatent\sipopatent_cover_20180905',
            r'\\192.168.30.177\样例数据\sipopatent\sipopatent_cover_20180913',
            r'\\192.168.30.177\样例数据\sipopatent\sipopatent_cover_20180918',
            r'\\192.168.30.177\样例数据\sipopatent\sipopatent_cover_20180921']

def Main():
    # 先修改文件名
    for FileRoot in FileRoots:
        for parent, dirnames, filenames in os.walk(FileRoot):
            for filename in filenames:
                srcFile = os.path.join(parent, filename)
                app_id = filename.replace(".jpg", "")
                try:
                    pub_no = dicts2[app_id]
                except:
                    print(app_id)
                    BaseDir.single_add_file("./id.txt", app_id+"\n")

Main()

